<?php if(!defined('IN_APP')) exit('No direct script access allowed');

class Controller implements ArrayAccess
{
    public $data = array();
    
    public function view($view, $data=array())
    {
        
    }
    
    public function __get($name) {
        if(array_key_exists($name, $this))
        {
            return $this->$name;
        }
        switch($name)
        {
            case 'db' :
                $db = new Database();
                return $db;
                break;
        }
    }
    public function __set($name, $value) {
        if(array_key_exists($name, $this))
        {
            $this->$name = $value;
            return $this->$name;
        }
        switch($name)
        {
            case 'db' :
                $this->db = new Database();
                break;
        }
    }
    
    public function offsetSet($offset, $value)
    {
        $this->data[$offset] = $value;
        return $this->data['offset'];
    }
    public function offsetGet($offset)
    {
        return isset($this->data[$offset]) ? $this->data[$offset] : '';
    }
    public function offsetUnset($offset)
    {
        $this->data[$offset] = '';
        unset($this->data[$offset]);
        return;
    }
    public function offsetExists($offset)
    {
        return isset($this->data[$offset]);
    }
}
/* EOF: Controller.php */